package com.framework.base.annontation;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * @author chaolong.jin
 * @description
 * @date 2019/07/12 10:06
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
//        final ThreadLocal<Integer> num = new ThreadLocal<>();
//        num.set(1);
//        ThreadLocal<Integer> s = new ThreadLocal<>();
//        s.set(2);
//        s.get();
//        FutureTask futureTask = new FutureTask(new Callable() {
//            @Override
//            public Object call() throws Exception {
//                System.out.println("futureTask");
//                return null;
//            }
//        });

//        futureTask.run();
        List<Callable<Void>> callableList=new ArrayList<>();
        final ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(1,10,1,TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(20){});
        for(int i=0;i<30;i++){
            Callable callable=new Callable() {
                @Override
                public Object call() throws Exception {
//                    Thread.sleep(2000);
                    System.out.println(Thread.currentThread().getName()+"---invoke  "+ threadPoolExecutor.getQueue().size());
                    return null;
                }
            };
            callableList.add(callable);
        }
        threadPoolExecutor.invokeAll(callableList);
        //        threadPoolExecutor.invokeAll((Collection<? extends Callable<Object>>) Arrays.asList(futureTask));
//        LockSupport.park();
//        Thread.sleep(5000);
//        LockSupport.park();



    }

    static class T extends ThreadLocal {
        public void getd() {

        }
    }
}
